﻿

//function customBannerResource() {
//   var oTable= $('#search_datatable').dataTable(
//        {
//            "iDisplayLength": 25,
//            "fnRowCallback": function(nRow, aData, iDisplayIndex) {

//            var chkName = "#chkResourceID_" + aData[1];
//                // Deal with a click on each row
//                $(nRow).click(function() {
//                // Check if we are adding or removing a row
//               
//                    if ($(chkName).is(':checked') == true){
//                        $(chkName).attr('checked', false);

//                    }

//                    else {
//                       
//                       
//                        $(chkName).attr('checked', true);

//                    }

//                    // Change the class based on selection
//                    this.className = ($(chkName).is(':checked') == true) ?
//                        this.className + '_selected' : this.className.replace(/_selected/, "");
//                }
//                );

//                /* For each draw - set the class based on the stored data */
//                nRow.className = ($(chkName).is(':checked') == true) ?
//				nRow.className + '_selected' :
//			 	nRow.className.replace(/_selected/, "");

//                return nRow;

//            }
//        }
//        );

//        return oTable;
//    }

    function customTable(containerName, startCheckBoxName) {
        var oTable = $(containerName).dataTable(
        {
            "iDisplayLength": 25,
            "fnRowCallback": function(nRow, aData, iDisplayIndex) {

            var chkName = startCheckBoxName + aData[1];
                // Deal with a click on each row
                $(nRow).click(function() {
                    // Check if we are adding or removing a row

                    if ($(chkName).is(':checked') == true) {
                        $(chkName).attr('checked', false);

                    }

                    else {


                        $(chkName).attr('checked', true);

                    }

                    // Change the class based on selection
                    this.className = ($(chkName).is(':checked') == true) ?
                        this.className + '_selected' : this.className.replace(/_selected/, "");
                }
                );

                /* For each draw - set the class based on the stored data */
                nRow.className = ($(chkName).is(':checked') == true) ?
				nRow.className + '_selected' :
			 	nRow.className.replace(/_selected/, "");

                return nRow;

            }
        }
        );

        return oTable;
    }
    

    
    function createTable() {
        var oTable = $('#search_datatable').dataTable(
        {
            "iDisplayLength": 25
        })
    }
            

//    function customBannerPosition() {
//        var oTablePosition = $('#search_datatable_position').dataTable(
//        {
//            "iDisplayLength": 25,
//            "fnRowCallback": function(nRow, aData, iDisplayIndex) {
//                // Deal with a click on each row
//                $(nRow).click(function() {
//                    // Check if we are adding or removing a row
//                    if (aData[4] == 1) {
//                        aData[4] = 0;
//                        var chkName = "#chkPositionID_" + aData[1];
//                        $(chkName).attr('checked', false);

//                    }

//                    else {
//                        aData[4] = 1;
//                        var chkName = "#chkPositionID_" + aData[1];
//                        $(chkName).attr('checked', true);

//                    }

//                    // Change the class based on selection
//                    this.className = (aData[4] == 1) ?
//                        this.className + '_selected' : this.className.replace(/_selected/, "");
//                }
//                );

//                /* For each draw - set the class based on the stored data */
//                nRow.className = (aData[4] == 1) ?
//				nRow.className + '_selected' :
//			 	nRow.className.replace(/_selected/, "");

//                return nRow;

//            }
//        }
//        );

//        return oTablePosition;
//    }


    function setEditSelected(startCheckBoxNames) {


        $(".even").each(function() {
            var filter = "input[name^='" + startCheckBoxNames + "']";
            var checkBox = $(filter, this);
            if (checkBox.is(':checked') == true) {

                $(this).attr("class", "even_selected");
            }
        }
           );

        $(".odd").each(function() {
            var filter = "input[name^='" + startCheckBoxNames + "']";
            var checkBox = $(filter, this);
            if (checkBox.is(':checked') == true) {

                $(this).attr("class", "odd_selected");
            }
        }
           );
    }